package com.lgst.example;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.Toast;

import com.lgst.carousel.CarouselController;
import com.lgst.carousel.CarouselInfo;
import com.lgst.carousel.CarouselView;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity {

    private CarouselView mCarousel;
    private CarouselView mCarousel2;
    private CarouselView mCarousel3;
    private List<CarouselInfo> ads = new ArrayList();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
    }

    private void initdata() {
        CarouselInfo ad1 = new CarouselInfo();
        ad1.setPictureUrl("http://img.zcool.cn/community/03320dd554c75c700000158fce17209.jpg");
        ads.add(ad1);

        CarouselInfo ad2 = new CarouselInfo();
        ad2.setPictureUrl("http://img05.tooopen.com/images/20160121/tooopen_sy_155168162826.jpg");
        ads.add(ad2);

        CarouselInfo ad3 = new CarouselInfo();
        ad3.setPictureUrl("http://img05.tooopen.com/images/20150830/tooopen_sy_140703593676.jpg");
        ads.add(ad3);
        CarouselInfo ad4 = new CarouselInfo();
        ad4.setPictureUrl("http://img02.tooopen.com/images/20160408/tooopen_sy_158723161481.jpg");
        ads.add(ad4);
    }

    private void initView() {
        initdata();
        mCarousel = (CarouselView) findViewById(R.id.carousel);
        mCarousel2 = (CarouselView) findViewById(R.id.carousel2);
        mCarousel3 = (CarouselView) findViewById(R.id.carousel3);
        mCarousel.init(ads);
        mCarousel.setOnItemClickListener(new CarouselController.OnItemClickListener() {
            @Override
            public void OnItemClickListener(int position) {
                Toast.makeText(getApplicationContext(), "Carousel-"+position, Toast.LENGTH_SHORT).show();
            }
        });
        mCarousel2.init(ads);
        mCarousel3.init(ads);
    }
}
